<!DOCTYPE html>
<html>
{% load staticfiles %}
{% load pagetag %}
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="author" content="Decade">
  <title>知识问答</title>
  <link rel="stylesheet" href="{% static 'libs/bootstrap/css/bootstrap.css' %}">
  <link rel="stylesheet" href="{% static 'libs/font-awesome/css/font-awesome.css' %}">
  <link rel="stylesheet" href="{% static 'libs/simditor/styles/simditor.css' %}">
  <link rel="stylesheet" href="{% static 'css/main.css' %}">
    <style>a:hover{text-decoration: none;}
        a{color: black}
    </style>
</head>

<body>
  <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="#">智游问答</a>
      </div>
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav">
          <li class="active"><a href="#">最新问题 <span class="sr-only">(current)</span></a></li>
          <li><a href="#">最难问题</a></li>
          <li><a href="/question/askto/">我的提问</a></li>
          <li><a href="/question/myanswer/">我的回答</a></li>
        </ul>
        <ul class="nav navbar-nav navbar-right">
          <li class="dropdown">
            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ user }} <span class="caret"></span></a>
            <ul class="dropdown-menu">
              <li><a href="#">个人信息</a></li>
              <li><a href="/auth/logout/">退出登录</a></li>
            </ul>
          </li>
        </ul>
      </div>
    </div>
  </nav>
  <div class="container">
    <div class="row">
      <div class="col-md-3 col-md-push-9">
        <form class="form-right" method="get" action="/question/">

          <div class="form-group">
            <div class="input-group">
              <input type="text" name="find_content" class="form-control" id="find" value="{{ find_content }}" placeholder="搜索问题">
              <span class="input-group-btn"><button  class="btn btn-default glyphicon glyphicon-search" id="submit" type="submit"></button></span>
            </div>
          </div>
        </form>
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title">分类</h3>
          </div>
          <div class="panel-body keywords">
          {% if not id %}
          <a  href="/question/?id2={{ id2 }}"><span class="label label-success" >全部</span></a>
          {% else %}
              <a  href="/question/?id2={{ id2 }}"><span class="label label-default" >全部</span></a>
          {% endif %}
              {% for a in type %}
                  {% if id == a.id %}
                  <a  href="/question/?id={{ a.id }}&id2={{ id2 }}"><span class="label label-success type" id="{{ a.id }}">{{ a.types }}</span></a>
                  {% else %}
                  <a  href="/question/?id={{ a.id }}&id2={{ id2 }}"><span class="label label-default type" id="{{ a.id }}">{{ a.types }}</span></a>
                  {% endif %}
              {% endfor %}
          </div>
        </div>
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title">标签</h3>
          </div>
          <div class="panel-body keywords">
          {% if not id2 %}
          <a  href="/question/?id={{ id }}"><span class="label label-success" >全部</span></a>
          {% else %}
              <a  href="/question/?id={{ id }}"><span class="label label-default" >全部</span></a>
          {% endif %}
              {% for a in tag %}
                  {% if id2 == a.id %}
                  <a  href="/question/?id2={{ a.id }}&id={{ id }}"><span class="label label-success type" id="{{ a.id }}">{{ a.tags }}</span></a>
                  {% else %}
                  <a  href="/question/?id2={{ a.id }}&id={{ id }}"><span class="label label-default type" id="{{ a.id }}">{{ a.tags }}</span></a>
                  {% endif %}
              {% endfor %}

          </div>
        </div>
      </div>
      <div class="col-md-9 col-md-pull-3">
        <div class="panel panel-default">
          <div class="panel-body question">
            <div class="row">
              <div class="col-xs-7">
                <h2>最新问题</h2>
              </div>
              <div class="col-xs-5 text-right">
                <a href="/question/askto/" class="btn btn-success add-question">&nbsp;<span class="glyphicon glyphicon-plus-sign"></span> 提问&nbsp;</a>
              </div>
            </div>
              {% for a in post %}
            <div class="media">
              <a class="media-left" href="#">
                <img class="media-object" src="">
              </a>
              <div class="media-body">

                <h4 class="media-heading"><a href="/question/answer/?id={{ a.id }}">{{ a.question }}</a></h4>
              <a href="/question/answer/?id={{ a.id }}">
                    {% autoescape off %}
                        {{ a.abstract }}
                    {% endautoescape %}</a>
                <div class="row keys">
                  <div class="col-md-8">
                      <span class="label label-success">{{ a.type.types }}</span>
                    <span class="label label-success">{{ a.tag.tags }}</span></div>
                  <div class="col-md-4 text-right">
                    <span class="label label-success nan" name="{{ a.id }}" id="f{{ a.id }}"  style="cursor: pointer">难</span></div>
                </div>
                <div class="time">
                  {{ a.submit_time }}&#x3000;{{ a.sub_user.username }}
                </div>
                  {% if a.answer_set.first %}
                      {% for a in a.answer_set.all %}
                          {% if forloop.counter <= 2 %}
                    <div class="media">
                  <a class="media-left" href="#">
                    <img class="media-object" src="">
                  </a>
                  <div class="media-body">
                    <h4 class="media-heading">回复者:{{ a.ans_user.username }}</h4>
                      {% autoescape off %}
                          {{ a.content }}
                      {% endautoescape %}
                    <div class="row keys">
                      <div class="col-md-8"><span class="label label-success">{{ a.ans_question.type.types }}</span>
                        <span class="label label-success">{{ a.ans_question.tag.tags}}</span></div>
                      <div class="col-md-4 text-right">
                          <span class="label label-danger " >赞</span></div>
                    </div>
                    <div class="time">
                      {{ a.ans_time }}
                    </div>
                  </div>
                </div>
                 {% endif %}
                {% endfor %}
                  {% endif %}
              </div>
            </div>
              {% endfor %}
            <div class="text-center">
             {% if post.object_list and post.paginator.num_pages > 1 %}
            <ul class="pagination">
            {% if post.has_previous %}
                <li><a href="/question/?page={{ post.previous_page_number }}&id={{ id }}&id2={{ id2 }}&find_content={{ find_content }}">上一页</a></li>
            {% else %}
                <li class="disabled"><a>上一页</a></li>
            {% endif %}

            {% for number in post.paginator.page_range %}
                {% if list %}
                {% circle_page post.number number %}
                {% else %}
                 {% circle2_page post.number id id2 find_content number %}
{#                <li class="disabled"><a>{{ forloop.counter }}</a></li>#}
                {% endif %}
            {% endfor %}

            {% if post.has_next %}
                <li><a href="/question/?page={{ post.next_page_number }}&id={{ id }}&id2={{ id2 }}&find_content={{ find_content }}">下一页</a></li>
            {% else %}
                <li class="disabled"><a>下一页</a></li></ul>
            {% endif %}
            {% endif %}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="text-center page-footer">
    <p class="visible-xs-block visible-sm-block visible-md-inline visible-lg-inline">智游教育问答 &nbsp;&nbsp; &copy;zhiyou100.com</p>
    <p class="visible-md-inline visible-lg-inline">&nbsp;&nbsp;</p>
    <p class="visible-md-inline visible-lg-inline">河南智游臻龙教育科技有限公司</p>
  </div>
  <script src="{% static 'libs/jquery/jquery.js' %}"></script>
  <script src="{% static 'libs/bootstrap/js/bootstrap.js' %}"></script>
  <script>
      $('.nan').each(function () {
          $(this).click(function () {
              id=$(this).attr('name');
              $.post(
                  '/question/toupiao/',
                  {'id':id,'stat':1},
                  function (data) {
                      $('#f'+id).html('难:'+data.num)
                  }
              )
          })
      });
      $('#find').change(function () {
            var a =document.getElementById('submit');
                a.click()
          }
      )
  </script>
</body>

</html>
